package com.example.smartcity_ikun3.ui.Smart.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.smartcity_ikun3.R
import com.example.smartcity_ikun3.ui.Smart.model.SmartFourEntity
import com.example.smartcity_ikun3.ui.Smart.model.SmartThreeEntity

class SmartMoreFourRecyclerViewAdapter (
    val data: List<SmartFourEntity>
) : RecyclerView.Adapter<SmartMoreFourRecyclerViewAdapter.ViewHolder>(){
    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
        val setTitle: TextView = view.findViewById(R.id.ThreeTitle)
        val setImageView: ImageView = view.findViewById(R.id.ThreeImageView)
        val setOn0: TextView = view.findViewById(R.id.ThreeOn0)
        val setOn1: TextView = view.findViewById(R.id.ThreeOn1)
        val setOn2: TextView = view.findViewById(R.id.ThreeOn2)
        val setOn3: TextView = view.findViewById(R.id.ThreeOn3)
        val setOn4: TextView = view.findViewById(R.id.ThreeOn4)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val root = LayoutInflater.from(parent.context).inflate(R.layout.re_item_smart_four, parent, false)
        val view = ViewHolder(root)

        return view
    }

    override fun getItemCount(): Int = data.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val list = data[position]
        holder.setTitle.text = list.threeTitle
        holder.setOn0.text = list.threeOn0
        holder.setImageView.setImageResource(list.threeImageView)
        holder.setOn1.text = list.threeOn1
        holder.setOn2.text = list.threeOn2
        holder.setOn3.text = list.threeOn3
        holder.setOn4.text = list.threeOn4
    }
}
